package com.corex.vinayak;

import java.util.List;

import com.corex.data.AllEnrolledClassData;
import com.corex.utils.Constants;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class SubjectActivity extends Activity{
	ListView listView;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.subject_layout);
		listView = (ListView) findViewById(R.id.subjects_list);
		 final List<String> values = AllEnrolledClassData.getAllNotesSubject("0");
		
		 ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
	              android.R.layout.simple_list_item_1, android.R.id.text1, values);
	    
		 listView.setAdapter(adapter);
		 
		 listView.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view, int position,
					long id) {
				String subjectName = values.get(position);
				String selection = (String) getIntent().getExtras().get(Constants.SELECTION);
				String[] values = Constants.values;
				
				Intent intent = null;
				if(selection.equalsIgnoreCase(values[0])){
					intent = new Intent(SubjectActivity.this, NotesActivity.class);
				}else if(selection.equalsIgnoreCase(values[1])){
					intent = new Intent(SubjectActivity.this, ExamActivity.class);
				}else if(selection.equalsIgnoreCase(values[2])){
					intent = new Intent(SubjectActivity.this, ProgressActivity.class);
				}
				
				startActivity(intent);
			}
		});
	    
	}
}
